package com.onpositive.data.diskstorage;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

import com.onpositive.data.ISeekableAccess;

public class ByteBufferSeekableAcess  implements ISeekableAccess{

	DataInputStream str;
	byte[] buf;
	
	public ByteBufferSeekableAcess(byte[] buf){
		this.buf=buf;
	}

	public final int read(byte[] b) throws IOException {
		return str.read(b);
	}

	public int read() throws IOException {
		return str.read();
	}

	public int hashCode() {
		return str.hashCode();
	}

	public final void read(byte[] b, int off, int len) throws IOException {
		str.readFully(b, off, len);
	}

	public boolean equals(Object obj) {
		return str.equals(obj);
	}

	public long skip(long n) throws IOException {
		return str.skip(n);
	}

	public int available() throws IOException {
		return str.available();
	}

	public final void readFully(byte[] b) throws IOException {
		str.readFully(b);
	}

	public void close() throws IOException {
		str.close();
	}

	public void mark(int readlimit) {
		str.mark(readlimit);
	}

	public final void readFully(byte[] b, int off, int len) throws IOException {
		str.readFully(b, off, len);
	}

	public void reset() throws IOException {
		str.reset();
	}

	public final int skipBytes(int n) throws IOException {
		return str.skipBytes(n);
	}

	public boolean markSupported() {
		return str.markSupported();
	}

	public final boolean readBoolean() throws IOException {
		return str.readBoolean();
	}

	public String toString() {
		return str.toString();
	}

	public final byte readByte() throws IOException {
		return str.readByte();
	}

	public final int readUnsignedByte() throws IOException {
		return str.readUnsignedByte();
	}

	public final short readShort() throws IOException {
		return str.readShort();
	}

	public final int readUnsignedShort() throws IOException {
		return str.readUnsignedShort();
	}

	public final char readChar() throws IOException {
		return str.readChar();
	}

	public final int readInt() throws IOException {
		return str.readInt();
	}

	public final long readLong() throws IOException {
		return str.readLong();
	}

	public final float readFloat() throws IOException {
		return str.readFloat();
	}

	public final double readDouble() throws IOException {
		return str.readDouble();
	}

	public final String readLine() throws IOException {
		return str.readLine();
	}

	public final String readUTF() throws IOException {
		return str.readUTF();
	}

	@Override
	public void seek(int intSize) throws IOException {
		str=new DataInputStream(new ByteArrayInputStream(buf));
		str.skip((long)intSize);
	}

}
